package com.bodu.depress.controller;

import com.bodu.core.common.AbstractCommonController;
import com.bodu.core.entity.ParamReq;
import com.bodu.core.entity.result.PageResult;
import com.bodu.core.entity.result.Result;
import com.bodu.depress.entity.request.DepressCollectDetailRequest;
import com.bodu.depress.entity.vo.DepressCollectDetailVo;
import com.bodu.depress.service.DepressCollectDetailService;
import com.bodu.global.annon.TraceLog;
import com.bodu.global.security.LoginUserUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* 题集明细 API
* @author Administrator
*/
@Api(tags = "题集明细 API")
@RestController
@RequestMapping("/depressCollectDetail")
public class DepressCollectDetailController extends AbstractCommonController<DepressCollectDetailService, DepressCollectDetailRequest, DepressCollectDetailVo> {

    private final DepressCollectDetailService depressCollectDetailService;

    public DepressCollectDetailController(DepressCollectDetailService depressCollectDetailService) {
        this.depressCollectDetailService = depressCollectDetailService;
    }

    @TraceLog()
    @GetMapping("{id}")
    public Result getModel(@PathVariable("id") Long id) {
        return super.getModel(depressCollectDetailService, id);
    }

    @TraceLog()
    @PostMapping
    @ApiOperation("保存题集明细")
    public Result<Integer> save(@RequestBody DepressCollectDetailRequest request) {
        request.setCreateUser(LoginUserUtil.getUserId());
        return super.save(depressCollectDetailService, request);
    }

    @TraceLog()
    @PutMapping
    @ApiOperation("更新题集明细")
    public Result<Integer> update(@RequestBody DepressCollectDetailRequest request) {
        request.setCreateUser(LoginUserUtil.getUserId());
        return super.update(depressCollectDetailService, request);
    }

    @TraceLog()
    @PostMapping("listPage")
    @ApiOperation("题集明细-查询")
    public Result<List<DepressCollectDetailVo>>listPage(@RequestBody ParamReq req) {
        return super.listPage(depressCollectDetailService, req);
    }

    @TraceLog()
    @PostMapping("countPage")
    @ApiOperation("题集明细-统计")
    public Result<Integer> countPage(@RequestBody ParamReq req) {
        return super.countPage(depressCollectDetailService, req);
    }

    @TraceLog()
    @PostMapping("page")
    @ApiOperation("题集明细-分页数据")
    public Result<PageResult> page(@RequestBody ParamReq<DepressCollectDetailRequest> req) {
        return super.page(depressCollectDetailService, req);
    }

    @TraceLog()
    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除题集明细")
    public Result<Integer> delete(@PathVariable("id") Long id) {
        return super.delete(depressCollectDetailService, id);
    }

    @TraceLog()
    @ApiOperation("批量删除题集明细")
    @DeleteMapping("{ids}")
    public Result<Integer> batchDelete(List<Long> ids) {
        return super.batchDelete(depressCollectDetailService, ids);
    }

    @Override
    public Long getLoginUserId() {
        return LoginUserUtil.getUserId();
    }

}
